package com.riku.demo.controller;

import com.riku.demo.service.TestService;
import com.riku.demo.tryagain.config.TryAgainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "测试类")
@RestController
@RequestMapping("/demo/test")
public class TestController {

    @Autowired
    private TryAgainService tryAgainService;

    @Autowired
    private TestService testService;

    @ApiOperation(value = "do error")
    @GetMapping("/doError")
    public void doError(
            @ApiParam(value = "id", required = false) @RequestParam(value = "id",required = false) Long id
    ) {
        testService.getOne(id);
    }

    @ApiOperation(value = "try again")
    @GetMapping("/tryAgain")
    public void tryAgain(
                @ApiParam(value = "error id", required = false) @RequestParam(value = "id",required = false) String id
        ) throws Exception {
        tryAgainService.tryAgain(id);
    }

}
